﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using libDAL;

namespace libCommonTools.BUS
{
    sealed class clsBUSFindGRN : IDisposable 
    {
        private struct srtQueries
        {
            public string get_QueryFindGRN(string strTop, string strFieldSearch, string strValue)
            {
                return "SELECT top(" + strTop + ") tfcargorec.connoteno, mfcompany.comname AS shipname,mfcompany_1.comname AS conname, " +
                       "tfcargorec.connotedate, shipinvno, tfcargorec.trastacode , " +
                       "tfcargorec.stickno, tfcargorec.shipid, tfcargorec.conid, tfcargorec.refno, " +
                       "tfcargorec.portid,  tfcargorec.speins, " +
                       "tfcargorec.totqty, tfcargorec.totcbm, tfcargorec.totwei, tfcargorec.issby, " +
                       "tfcargorec.vehplano ,tfcargorec.grntypecode " +
                       "FROM tfcargorec LEFT OUTER JOIN " +
                       "mfcompany AS mfcompany_1 ON tfcargorec.conid = mfcompany_1.comid RIGHT OUTER JOIN " +
                       "mfcompany ON tfcargorec.shipid = mfcompany.comid " +
                       "WHERE " + strFieldSearch + " LIKE '%" + strValue + "%'";
            }

            public string get_QueryFindGRNDetails(string strGRNNo)
            {

                return "SELECT tfcargorec.connoteno, tfcargorec.temconnoteno, tfcargorec.orderno, tfcargorec.jobfileno, tfcargorec.connotedate, tfcargorec.connotetime, tfcargorec.vehplano, " +
                       "tfcargorec.shipid, mfcompany.comname, tfcargorec.shipline1, tfcargorec.shipline2, tfcargorec.shipline3, tfcargorec.shipline4, tfcargorec.shipline5, tfcargorec.conid," +
                       "mfcompany_1.comname AS consigneeName, tfcargorec.conline1, " +
                       "tfcargorec.conline2, tfcargorec.conline3, tfcargorec.conline4, tfcargorec.conline5, tfcargorec.portid, tfcargorec.tosales, tfcargorec.instype, tfcargorec.dtduntil, " +
                       "tfcargorec.speins, tfcargorec.issby, tfcargorec.schcode, tfcargorec.trastacode, tfcargorec.startjob, tfcargorec.optcode, tfcargorec.appby, tfcargorec.apprem, " +
                       "tfcargorec.oldstoapp, tfcargorec.oldstorea, tfcargorec.shipinv, tfcargorec.shipdo, tfcargorec.shipinvno, tfcargorec.shipdono, tfcargorec.totwei, tfcargorec.totqty, " +
                       "tfcargorec.stickno, tfcargorec.totcbm, tfcargorec.grntypecode, tfcargorec.bill, tfcargorec.shipstatecode, tfcargorec.shipcitycode, tfcargorec.shippostcode, " +
                       "tfcargorec.shiptelpre, tfcargorec.shiptelno, tfcargorec.shipfaxpre, tfcargorec.shipfaxno, tfcargorec.constatecode, tfcargorec.concitycode, tfcargorec.conpostcode, " +
                       "tfcargorec.contelpre, tfcargorec.contelno, tfcargorec.confaxpre, tfcargorec.confaxno, tfcargorec.totloadqty, tfcargorec.totbalance, tfcargorec.refno, tfcargorec.loadwei, " +
                       "tfcargorec.loadcbm, tfcargorec.meno, tfcargorec.recby, tfcargorec.onhold, tfcargorec.onholddate, tfcargorec.termver, tfcargorec.termverby, tfcargorec.meaver, " +
                       "tfcargorec.meaverby, tfcargorec.byshipmea, tfcargorec.shipcbm, tfcargorec.shipwei, tfcargorec.shipqty, tfcargorec.insvalue, tfcargorec.insvaluef, tfcargorec.byshipins, " +
                       "tfcargorec.nbl, tfcargorec.obl, tfcargorec.saltercode, tfcargorec.billremarks, tfcargorec.pman, tfcargorec.pcn, tfcargorec.pinv, tfcargorec.byci, tfcargorec.termverdate, " +
                       "tfcargorec.intvehicle, tfcargorec.vehtrip, tfcargorec.cancelby, tfcargorec.cancelrea, tfcargorec.speinsport, tfcargorec.releaseby, tfcargorec.releasedate, " +
                       "tfcargorec.releaserea, tfcargorec.billbyfcl, tfcargorec.cashbill, tfcargorec.comid, tfcargorec.billagent, tfcargorec.billbranch, tfcargorec.bsaltercode, tfcargorec.bbill, " +
                       "tfcargorec.hakgerakanby, tfcargorec.meaverdate, tfcargorec.conareacode, tfcargorec.shipareacode, tfcargorec.cusdec, tfcargorec.cusdecby, tfcargorec.cusdecdate, " +
                       "tfcargorec.vehtripdate, tfcargorec.grnVerified, tfcargorec.grnVerifiedBy " +
                       "FROM tfcargorec LEFT OUTER JOIN " +
                       "mfcompany AS mfcompany_1 ON tfcargorec.shipid = mfcompany_1.comid LEFT OUTER JOIN " +
                       "mfcompany ON tfcargorec.conid = mfcompany.comid " +
                       "WHERE LTRIM(RTRIM(tfcargorec.connoteno)) = '" + strGRNNo.Trim() + "'";
            }
        }

        private struct VariableHolder
        {
            public DataTable dtQueryResult;
            public cls_DAL _DAL;
            public string strFindType;
        }

       private srtQueries getQueries;
       private VariableHolder VarHolder;

       public clsBUSFindGRN()
       { 
        
       }

        public void Dispose()
        {
            GC.Collect();
           // throw new NotImplementedException();
        }
    }
}
